package cn.edu.sdjzu.xg.service;

import cn.edu.sdjzu.xg.dao.SchoolDao;
import cn.edu.sdjzu.xg.domain.School;
import cn.edu.sdjzu.xg.util.Condition;
import cn.edu.sdjzu.xg.util.JdbcHelper;
import cn.edu.sdjzu.xg.util.Pagination;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

public class SchoolService {
    private static SchoolService schoolService = null;
    private static SchoolDao schoolDao = SchoolDao.getInstance();
    private SchoolService(){}
    public static SchoolService getInstance(){
        if (schoolService == null){
            schoolService = new SchoolService();
        }
        return schoolService;
    }
    //修改
    public boolean update(School school)throws SQLException {
        return schoolDao.update(school);
    }
    public School find(Integer id) throws SQLException{
        return SchoolDao.getInstance().find(id);

    }
    public Collection<School> findAll(List<Condition> conditionList, Pagination pagination)throws SQLException {
        Connection connection= JdbcHelper.getConn();
        Collection<School> schools = SchoolDao.getInstance().findAll(connection,conditionList,pagination);
        JdbcHelper.close(connection);
        return schools;


    }

}
